﻿using System;
using Microsoft.VisualStudio.OLE.Interop;

namespace DiveDeeper.VsxLibrary.Core
{
  // ==================================================================================
  /// <summary>
  /// This class represents the arguments of an IOleCommandTarget.Exec method.
  /// </summary>
  // ==================================================================================
  public class ExecArgs
  {
    #region Private fields

    private readonly Guid _GroupId;
    private readonly uint _CommandId;
    private uint _CommandExecOpt;
    private IntPtr _pvaIn;
    private IntPtr _pvaOut;

    #endregion

    #region Lifecycle methods

    // --------------------------------------------------------------------------------
    /// <summary>
    /// Creates a new instance of this class with the specified command identifiers.
    /// </summary>
    /// <param name="groupId">ID of the command group.</param>
    /// <param name="commandId">ID of the command within the group.</param>
    // --------------------------------------------------------------------------------
    public ExecArgs(Guid groupId, uint commandId)
    {
      _GroupId = groupId;
      _CommandId = commandId;
    }

    #endregion

    #region Public properties

    // --------------------------------------------------------------------------------
    /// <summary>
    /// Gets the ID of the command group.
    /// </summary>
    // --------------------------------------------------------------------------------
    public Guid GroupId
    {
      get { return _GroupId; }
    }

    // --------------------------------------------------------------------------------
    /// <summary>
    /// Gets the ID of the command within the group.
    /// </summary>
    // --------------------------------------------------------------------------------
    public uint CommandId
    {
      get { return _CommandId; }
    }

    public uint CommandExecOpt
    {
      get { return _CommandExecOpt; }
      set { _CommandExecOpt = value; }
    }

    public IntPtr PvaIn
    {
      get { return _pvaIn; }
      set { _pvaIn = value; }
    }

    public IntPtr PvaOut
    {
      get { return _pvaOut; }
      set { _pvaOut = value; }
    }

    #endregion
  }

  // ==================================================================================
  /// <summary>
  /// This class represents the arguments of an IOleCommandTarget.QueryStatus method.
  /// </summary>
  // ==================================================================================
  public sealed class QueryStatusArgs
  {
    #region Private fields

    private readonly Guid _GroupId;
    private uint _CommandCount;
    private OLECMD[] _Commands;
    private IntPtr _pCmdText;

    #endregion

    #region Lifecycle methods

    public QueryStatusArgs(Guid groupId)
    {
      _GroupId = groupId;
    }

    #endregion

    #region Public properties

    public Guid GroupId
    {
      get { return _GroupId; }
    }

    public uint CommandCount
    {
      get { return _CommandCount; }
      set { _CommandCount = value; }
    }

    public OLECMD[] Commands
    {
      get { return _Commands; }
      set { _Commands = value; }
    }

    public IntPtr PCmdText
    {
      get { return _pCmdText; }
      set { _pCmdText = value; }
    }

    public uint FirstCommandId
    {
      get { return _Commands[0].cmdID; }
    }

    public uint FirstCommandStatus
    {
      get { return _Commands[0].cmdf; }
      set { _Commands[0].cmdf = value; }
    }

    #endregion
  }
}
